{% extends 'system_template/public/base_main.html' %}
{% block cite %}
    IP黑名单
{% endblock %}
{% block content %}
    <form class="layui-form search">
        <div class="layui-inline layui-show-xs-block">
            <input type="text" name="add_ip" placeholder="输入需禁止访问的IP" class="layui-input" lay-verify="required">
        </div>
        <div class="layui-inline layui-show-xs-block">
            <a class="layui-btn layui-btn-normal" id="sub_ip"><i class="layui-icon"></i>添加限制</a> <span style="color: #D1D1D1;margin-left: 25px;">添加成功自动刷新</span>
        </div>
    </form>
    <table class="layui-table layui-form">
        <thead>
        <tr>
            <th>
                <input type="checkbox" lay-skin="primary" lay-filter="c_all">
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i
                        class="layui-icon layui-icon-ok"></i></div>
            </th>
            <th>IP地址</th>
            <th>IP来路</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {% for data in data_list %}
            <tr>
                <td>
                    <input type="checkbox" name="checkbox" lay-skin="primary" value="{{ data.IP }}">
                    <div class="layui-unselect layui-form-checkbox" lay-skin="primary">
                        <i class="layui-icon layui-icon-ok"></i>
                    </div>
                </td>
                <td>{{ data.IP }}</td>
                <td>{{ data.address }}</td>
                <td class="td-manage">
                    <a class="but_sm del_but" title="移出限制" onclick="other(this,'{{ data.IP }}','移出限制','DELETE')" href="javascript:;">移出限制</a>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    <script>
        $('#sub_ip').click(function () {
            ele = $('input[name="add_ip"]');
            if (ele.val()) {
                var re = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
                var x = ele.val().match(re);
                if (x != null) {
                    other(this, ele.val(), '添加限制', 'POST');
                } else {
                    layer.msg('失败: 请输入合法IP', {icon: 2, time: 2000});
                    return false
                }
                ele.val('')
            }
        })
    </script>
{% endblock %}
